function Utf8Encode(_input){
var result = new Array();
var _H = false;
var _r = 0x0;
for (var _i = 0; _i < _input.length; _i++) {
var _c = _input.charCodeAt(_i);
if ((!_H && (0x0 <= _c) && (_c <= 0x7F))){
result.push(String.fromCharCode(_c));
}
else if ((!_H && (0x7F < _c) && (_c <= 0x7FF))){
result.push(String.fromCharCode((0xC0 | ((_c >> 0x6) & 0x1F)), (0x80 | (_c & 0x3F))));
}
else if ((!_H && (0x7FF < _c) && (_c <= 0xFFFF) && ((_c < 0xD800) || (_c > 0xDFFF)))){
result.push(String.fromCharCode((0xE0 | ((_c >> 0xC) & 0xF)), (0x80 | ((_c >> 0x6) & 0x3F)), (0x80 | (_c & 0x3F))));
}
else if ((!_H && (0xD800 <= _c) && (_c <= 0xDBFF))){
_H = true;
_r = (_c & 0x3);
result.push(String.fromCharCode((0xF0 | (((0x1 + ((_c >> 0x6) & 0xF)) >> 0x2) & 0x7)), ((0x80 | (((0x1 + ((_c >> 0x6) & 0xF)) & 0x3) << 0x4)) | ((_c >> 0x2) & 0xF))));
}
else if ((_H && (0xDC00 <= _c) && (_c <= 0xDFFF))){
_H = false;
_r = 0x0;
result.push(String.fromCharCode(((0x80 | (_r << 0x4)) | ((_c >> 0x6) & 0xF)), (0x80 | (_c & 0x3F))));
}
else if (true){
throw {name:'InvalidInput'};
}
}
if (_H){
throw {name:'InvalidInput'};
}
return result.join('');
}
